package com.food.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.food.dao.service.RecipeService;
import com.food.model.Member;
import com.food.model.Recipe;


@WebServlet("/member/MyRecipe")
public class MyRecipe extends HttpServlet {
	private static final long serialVersionUID = 1L;


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	
		
		
		RecipeService service = new RecipeService();
		
		HttpSession session = request.getSession();
		Member member = (Member)session.getAttribute("user");
		Recipe recipe = new Recipe();
		recipe.setMbid(member.getMbid());
		List<Recipe> coll = service.findRecipeByMb(recipe);
		request.setAttribute("mbRecipe", coll);
		RequestDispatcher rd = request
				.getRequestDispatcher("/member/memberindex.jsp");
		rd.forward(request, response);
		return;
		
	}

}
